<template>
  <div class="article-list-container">
    <div v-for="item in list" :key="item.id" class="article-item">
      <div class="comment-num">
        <span>0</span>
      </div>
      <div class="content">
        <p class="title">{{ item.article_title }}</p>
        <span class="desc">{{ item.article_desc }}</span>
      </div>
      <div class="user-info">
        <div class="author-info">
          <svg-icon class="icon" icon-class="people_fill"></svg-icon>
          <router-link :to="'/space?id=' + item.author_id">{{ item.author_name || 'testname' }}</router-link>
        </div>
        <div class="last-comment-info">
          <svg-icon v-if="item.last_comment_name" class="icon" icon-class="message"></svg-icon>
          <router-link :to="'/space?id=' + item.comment_id">{{ item.last_comment_name || '' }}</router-link>
        </div>
      </div>
      <div class="time">
        <span>{{ item.add_time || '17:36' }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ArticleList',
  props: {
    list: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="less" scoped>
.article-list-container {
  .article-item {
    padding: 5px 20px 20px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    &:hover {
      cursor: default;
      background-color: #f5f7f9;
    }
    .comment-num {
      width: 100px;
      flex-grow: 0;
      span {
        display: block;
        border: 1px solid #ccc;
        background-color: #f7f7f7;
        color: #333;
        font-size: 14px;
        text-align: center;
        line-height: 28px;
        height: 28px;
        width: 56px;
        margin: 5px 10px;
      }
    }
    .content {
      font-size: 14px;
      flex-grow: 1;
      width: 480px;
      .desc {
        cursor: pointer;
        flex-grow: 1;
        display: inline-block;
        overflow: hidden;
        width: 85%;
        text-overflow: ellipsis;
        white-space: nowrap;
        &:hover {
          color: royalblue;
        }
      }
      .title {
        margin: 0;
        font-size: 16px;
        font-weight: normal;
        line-height: 28px;
        cursor: pointer;
        flex-grow: 1;
        &:hover {
          color: royalblue;
        }
      }
    }
    .user-info {
      line-height: 28px;
      .author-info {
        font-size: 14px;
        width: 100px;
      }
      .last-comment-info {
        width: 100px;
      }
    }
    .icon {
      vertical-align: middle;
      margin-right: 10px;
      font-size: 16px;
    }
    .time {
      width: 80px;
      font-size: 12px;
      text-align: center;
      span {
        display: block;
        margin: 30px 0;
      }
    }
  }
}
</style>
